{extend name="base/common"}

{block name="style"}
<link rel="stylesheet" href="__STATIC__/datepicker/bootstrap-datetimepicker.min.css">
<link rel="stylesheet" href="__STATIC__/iCheck/custom.css">
<link rel="stylesheet" href="__ADMIN__/css/chosen/chosen.css">
<link rel="stylesheet" href="__HOME__/css/word/detail1.css">
<style>
    audio{
        margin-top:10px;
    }
    textarea{
        resize:none;
    }
    .imggroup{
        position: relative;
    }
    .imgbox{
        height: 100px;
        width: 200px;
        margin-top: 5px;
        margin-bottom: 0;
    }
    .imgfile{
        height: 100px;
        width: 200px;
        position: absolute;
        top:0;
        opacity: 0;
    }
    .modal-body{
        height: auto;
    }
    .preview-content{
        width: 375px;
        height: 667px;
        overflow-y: scroll;
        box-shadow: 1px 3px 8px rgba(153, 153, 153, 0.6);
    }
    .showbox {
        position: absolute;
        top: 0;
        bottom: 0;
        left: 0;
        right: 0;
        padding: 5%;
        background: rgba(0, 0, 0, 0.3);
        display: none;
        z-index: 999;
    }

    .loader {
        position: relative;
        margin: 0 auto;
        width: 100px;
        margin-top: 30%;
    }
    .loader:before {
        content: '';
        display: block;
        padding-top: 50%;
    }

    .circular {
        animation: rotate 2s linear infinite;
        height: 100%;
        transform-origin: center center;
        width: 100%;
        position: absolute;
        top: 0;
        bottom: 0;
        left: 0;
        right: 0;
        margin: auto;
    }

    .path {
        stroke-dasharray: 1, 200;
        stroke-dashoffset: 0;
        animation: dash 1.5s ease-in-out infinite, color 6s ease-in-out infinite;
        stroke-linecap: round;
    }

    @keyframes rotate {
        100% {
            transform: rotate(360deg);
        }
    }
    @keyframes dash {
        0% {
            stroke-dasharray: 1, 200;
            stroke-dashoffset: 0;
        }
        50% {
            stroke-dasharray: 89, 200;
            stroke-dashoffset: -35px;
        }
        100% {
            stroke-dasharray: 89, 200;
            stroke-dashoffset: -124px;
        }
    }
    @keyframes color {
        100%,
        0% {
            stroke: #d62d20;
        }
        40% {
            stroke: #0057e7;
        }
        66% {
            stroke: #008744;
        }
        80%,
        90% {
            stroke: #ffa700;
        }
    }
    .element.style {
        margin: 4vw auto 0;
        width: 82.3vw;
        background: #fff;
    }
</style>
{/block}

{block name="page-header"}
<div class="row wrapper border-bottom white-bg page-heading">
    <div class="col-lg-10">
        <h2>每日一句</h2>
        <ol class="breadcrumb">
            <li>
                <a href="{:Url('index')}">主页</a>
            </li>
            <li class="active">
                <strong>{$msg['id'] ? "编辑":"新增"}</strong>
            </li>
        </ol>
    </div>
    <div class="col-lg-2">

    </div>
</div>
{/block}

{block name="main"}
<div class="wrapper wrapper-content animated fadeInRight">
    <div class="row">
        <div class="col-lg-12">
            <div class="ibox float-e-margins">
                <div class="ibox-title">
                    <h5>{$msg['id'] ? "编辑":"新增"}翻译</h5>
                    <div class="ibox-tools">
                        <a href="javascript:window.history.go(-1);" class="btn btn-white btn-sm"><i class="fa fa-reply"></i> 返回</a>
                    </div>
                </div>
                <div class="ibox-content">
                    <form id="form" class="form-horizontal" method="post" enctype="multipart/form-data">
                        <div class="form-group">
                            <div class="col-lg-1 text-right control-label">
                                <label>类型:</label>
                            </div>
                            <div class="col-lg-11">
                                <select class="form-control" name="type">
                                    {neq name="msg" value=""}
                                    <option value="1" {eq name="msg.type" value="1"} selected {/eq}>考研</option>
                                    <option value="2" {eq name="msg.type" value="2"} selected {/eq} >专升本</option>
                                    <option value="3" {eq name="msg.type" value="3"} selected {/eq} >四六级</option>
                                    <option value="4" {eq name="msg.type" value="4"} selected {/eq} >雅思</option>
                                    <option value="5" {eq name="msg.type" value="5"} selected {/eq} >托福</option>
                                    {else/}
                                    <option value="1" >考研</option>
                                    <option value="2" >专升本</option>
                                    <option value="3" >四六级</option>
                                    <option value="4" >雅思</option>
                                    <option value="5" >托福</option>
                                    {/neq}
                                </select>
                            </div>
                        </div>
                        <div class="form-group">
                            <div class="col-lg-1 text-right control-label">
                                <label>标题:</label>
                            </div>
                            <div class="col-lg-11">
                                <input type="text" placeholder="请输入标题" class="form-control form_title" name="title" value='{$msg.title || default=""}'>
                            </div>
                        </div>
                        <div class="form-group">
                            <div class="col-lg-1 text-right control-label">
                                <label>日期:</label>
                            </div>
                            <div class="col-lg-11">
                                <div class="date">
                                    {empty name="msg"}
                                    <input type="text" placeholder="请输入日期" class="form-control datetimepicker " name="create_time"  value=""/>
                                    {else/}
                                    <input type="text" placeholder="请输入日期" class="form-control datetimepicker " name="create_time"  value="{$msg.create_time|time_format='Y-m-d'}"/>
                                    {/empty}
                                </div>
                            </div>
                        </div>
                        <div class="form-group">
                            <div class="col-lg-1 control-label">
                                <label>内容:</label>
                            </div>
                            <div class="col-lg-11">
                                <div class=" float-e-margins">
                                    <div class="ibox-content no-padding borders">
                                        <script id="container" name="content" type="text/plain">{$msg.content||default=''}</script>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <input type="hidden" name="id" value="{$msg.id||default=''}">
                        <div class="form-group">
                            <div class="col-lg-11 col-lg-offset-1">
                                <button class="btn btn-primary submit-btn post-add" type="button" target-form="form-horizontal" >发布</button>
                                <a class="btn btn-default" href="javascript:window.history.go(-1);">返回</a>
                            </div>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>
<div class="showbox">
    <div class="loader">
        <svg class="circular" viewBox="25 25 50 50">
            <circle class="path" cx="50" cy="50" r="20" fill="none" stroke-width="2" stroke-miterlimit="10"/>
        </svg>
    </div>
</div>
{/block}

{block name="script"}
<script src="__STATIC__/uploadify/jquery.uploadify.min.js"></script>
<script src="__STATIC__/iCheck/icheck.min.js"></script>
<script src="__STATIC__/datepicker/bootstrap-datetimepicker.js"></script>
<script src="__STATIC__/ueditor/ueditor.config.js"></script>
<script src="__STATIC__/ueditor/ueditor.all.min.js"></script>
<script src="__ADMIN__/js/chosen.jquery.js"></script>
<script>
    $(function(){
        //导航高亮
        highlight_subnav("{:Url('index')}");
        //百度编辑器
        var ue = UE.getEditor('container',{
            initialFrameHeight:400
        });
        //    时间日历
        var date = new Date();
        $( ".datetimepicker" ).datetimepicker( {
            language:  'zh-CN',
            startDate: date,
            autoclose: true,
            minView: 2,
            todayBtn: true,
            todayHighlight: 1,
            forceParse: true,
            format: 'yyyy-mm-dd',
        });
        $(".post-add").on("click",function(){
            /*重组轮播图，删除多余字符串（i是键值，1表示几位开始*/
            var it=$(this);
            if ($("input[name='create_time']").val() == ''){
                updateAlert('日期不能为空', 'error');
                return false;
            }
            var data = {
                id:$("input[name='id']").val(),
                type:$("select[name='type']").val(),
                title:$("input[name='title']").val(),
                content:ue.getContent(),
                create_time:$("input[name='create_time']").val(),
            };
            $.ajax({
                type:"post",
                url:$("#form").attr("action"),
                data:data,
                success:function(data){
                    if(data.code == 1){
                        if (data.url) {
                            updateAlert(data.msg + ' 页面即将自动跳转~','success');
                        }else{
                            updateAlert(data.msg ,'success');
                        }
                        it.prop('disabled','true');
                        it.next('button').prop('disabled','true');
                        setTimeout(function(){
                            if (data.url) {
                                location.href=data.url;
                            } else {
                                location.reload();
                            }
                            it.removeAttr('disabled');
                            it.next('button').removeAttr('disabled')
                        },2000);
                    } else {
                        updateAlert(data.msg, 'error');
                        it.attr('disabled','true');
                        it.next('button').prop('disabled','true');
                        setTimeout(function(){
                            it.removeAttr('disabled');
                            it.next('button').removeAttr('disabled')
                        },2000);
                    }
                }
            });
            return false;
        });

    })
</script>


<!--时间日历-->
<script type="text/javascript">

    $(function(){
        //    单选按钮
        $('.i-checks').iCheck({
            checkboxClass: 'icheckbox_square-green',
            radioClass: 'iradio_square-green'
        });

    })

</script>
{/block}